package com.fengmi.controller;

import com.fengmi.dto.PageDTO;
import com.fengmi.entity.MallGoodsBrand;
import com.fengmi.service.MallGoodsBrandService;
import com.fengmi.vo.PageResoultVo;
import com.fengmi.vo.ResoultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/brand")
@CrossOrigin
@Api(tags = "品牌管理")
public class MallGoodBrandController {
    @Autowired
    private MallGoodsBrandService mallGoodsBrandService;

    @PostMapping("/findPageBrand")
    @ResponseBody
    @ApiOperation("品牌分页接口")
    public PageResoultVo<MallGoodsBrand> page(@RequestBody @ApiParam("分页条件实体类")PageDTO<MallGoodsBrand> pageDTO){
        PageResoultVo<MallGoodsBrand> brandPageResoultVo = mallGoodsBrandService.selectPageGoodBrand(pageDTO);
        return brandPageResoultVo;
    }

    @PostMapping("/creatBrand")
    @ResponseBody
    @ApiOperation("添加品牌接口")
    public ResoultVo<MallGoodsBrand> creat(@RequestBody @ApiParam("添加条件实体类")MallGoodsBrand mallGoodsBrand){

        ResoultVo<MallGoodsBrand> mallGoodsBrandResoultVo = mallGoodsBrandService.creatGoodBrand(mallGoodsBrand);
        return mallGoodsBrandResoultVo;
    }

    @GetMapping("/deleteBrand")
    @ResponseBody
    @ApiOperation("根据id删除品牌接口")
    public ResoultVo del(@RequestParam("id") @ApiParam("品牌ID") String id){
        ResoultVo resoultVo = mallGoodsBrandService.delGoodBrandById(id);

        return resoultVo;
    }

    @PostMapping("/updateBrand")
    @ResponseBody
    @ApiOperation("修改品牌接口")
    public ResoultVo update(@RequestBody  @ApiParam("修改条件实体类")MallGoodsBrand mallGoodsBrand){
        ResoultVo resoultVo = mallGoodsBrandService.changeGoodBrand(mallGoodsBrand);

        return resoultVo;
    }

    @PostMapping("/findone")
    @ResponseBody
    @ApiOperation("查找一个品牌接口")
    public ResoultVo<MallGoodsBrand> findone(@RequestParam("id") @ApiParam("品牌ID") String id){
        ResoultVo<MallGoodsBrand> oneBrandById = mallGoodsBrandService.findOneBrandById(id);
        return  oneBrandById;
    }

    @GetMapping("/changeStatues")
    @ResponseBody
    @ApiOperation("根据id修改品牌属性接口")
    public ResoultVo changeStatues(@RequestParam("id") @ApiParam("品牌ID") String id, @RequestParam("status") @ApiParam("品牌状态") String status){
        ResoultVo brandPageResoultVo = mallGoodsBrandService.changeBrandStatusById(id,status);
        return brandPageResoultVo;
    }

    @PostMapping("/removeMore")
    @ResponseBody
    @ApiOperation("批量删除接口")
    public ResoultVo removeMore (@RequestBody @RequestParam("ids") @ApiParam("ID数组") String ids){
        ResoultVo brandPageResoultVo = mallGoodsBrandService.removeMore(ids);
        return brandPageResoultVo;
    }



}
